package com.interfaces;


import java.util.List;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.entity.Sysdic;

/**   
* @Title: SysdicDao.java 
* @Package com.interfaces 
* @author 孙梦楠 
* @date 2017年7月19日 下午4:42:02 
* @version V1.0.0   
*/

public interface SysdicDao extends JpaRepository<Sysdic, Integer>{
	
	//通过中文查实际值
	Sysdic findBySysdicdisplay(String sysdicdisplay);
	//通过value值查单条
	Sysdic findBySysdictypeAndSysdicvalue(String sysdictype,String sysdicvalue);
	
	@Transactional
	@Query(value = "SELECT s FROM Sysdic s WHERE s.sysdictype=?1 AND s.sysdicisdel=0")
	public List<Sysdic> findBySysdictype(String sysdictype);
	
	
	//通过type倒叙排序
	List<Sysdic> findBySysdictypeOrderBySysdicordDesc(String sysdictype);
	
	
	
	//修改字典状态
	@Transactional
	@Modifying
	@Query("update Sysdic s set s.sysdicisdel = ?1 where s.sysdicid=?2")
	int updateSysdicisdel(Byte sysdicisdel,Integer sysdicid);
	

}
